﻿using System;
using System.Collections.Generic;
using System.Text;
using CadStrategy2013.DxfData;
using MyTool.FileOpt;

namespace ReadDataGd_Ini
{
    public class ReadDataClass : ReadDataInterface
    {
        public DxfDataClass GetDxfData(string StationName, int BanCount)
        {
            DxfDataClass dxfDataClass = new DxfDataClass();

            IniFile inifile = new IniFile("./\\" + StationName + "\\gd.txt");
            inifile.Load();
            int sum0 = inifile.GetInt("轨道", "sum", 0);

            for (int i = 0; i < sum0; i++)
            {
                DevClass devClass = new DevClass();
                string strs = inifile.GetString("轨道", (i + 1).ToString());
                string[] s = strs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int n = s.Length;
                if (n == 0)
                {
                    devClass.DevName = " ";
                }
                else
                {
                    devClass.DevName = s[0];
                }
                if (n < 2)
                {
                    devClass.peiList.Add("");
                    devClass.peiList.Add("");
                }
                else
                {
                    devClass.peiList.Add(s[1]);
                    devClass.peiList.Add(s[2]);
                }
                dxfDataClass.devList.Add(devClass);
            }
            dxfDataClass.ShiJiBanCount = (dxfDataClass.devList.Count - 1) / dxfDataClass.BanDevCount + 1;
            dxfDataClass.ShiJiTuZhiCount = (dxfDataClass.ShiJiBanCount - 1) / BanCount + 1;
            return dxfDataClass;
        }
    }
}